var dateType = '1',  //日期类型
    dateStart = '', //开始日期
    dateEnd = '';   //结束日期
//用户选择
function selectSH(id) {
	var te = $("#SH").attr("btnType");
	if(te == "隐藏") {
		$("#SH").attr("btnType", "显示");
		$("#selectBox").fadeIn(600, function() {
			$("#selectBox").css("display", "block")
		})
	}
	if(te == "显示") {
		$("#SH").attr("btnType", "隐藏");
		$("#selectBox").fadeOut(600, function() {
			$("#selectBox").css("display", "none")
		})
	}
}
//用户选择结束

var userid='',zid='',zhandianid='';

//设置session参数
function setSessionfunc(typeid,zid,jfpg){
	//设置当前用户的session值
    //typeid 系统分类id (比如对应前端八大类), zid 当前用户的站点id
	var url="/bigscrenn/setUserSession?typeid="+typeid+"&zid="+zid+"&cid="+jfpg;
    $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
              console.log(data,'参数');         
	     }
    		
    });	
};
//jfpgVueFunc();
var vm;
function jfpgVueFunc() {
	vm = new Vue({
		el : "#app",
		data : {
			userid : "",   //用户id
			unitID : "",   //单位id
			userType : "", //用户类型
			kehu : [],     //左边列表
			zhandian : [], //站点数组
			zid : "",      //站点
			zName:'',       //站点名称
		    danweiID:'',    //单位id
		    danweiName:'',   //单位名称
		},
		mounted : function() {
			this.getSession();
		},
		methods : {
			//session
			getSession:function(){
				var vs = this;
				var userid,unitID,userType;
				var url="/bigscrenn/getUserSession";
			     $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
				    	 console.log("session数据：",data);
				    	 //js解析json串
			     	     var obj = JSON.parse(data);
			             if (obj.session.length>0){
			                   /*alert(obj.session[0].UserID);//用户id
			                   alert(obj.session[0].Name);//用户名称
			                   alert(obj.session[0].UnitID);//用户单位id
			                   alert(obj.session[0].UserAuthority);//用户权限 2 所有单位 3 本单位
			                   alert(obj.session[0].typeid);//系统分类id (比如对应前端八大类)
			                   alert(obj.session[0].zid);//当前用户的站点id*/			            	   
			            	   vs.userid = obj.session[0].UserID;
			 	  			   vs.unitID = obj.session[0].UnitID;
			 	  			   vs.userType = obj.session[0].UserAuthority;
			 	  			   
			 	  			   vs.danweiID = (obj.session[0].cid1).split(",")[0];  //单位id方法
			 	  			   vs.danweiName = (obj.session[0].cid1).split(",")[1];//上页选中来的单位名称
			 	  			   if(vs.danweiID==undefined){
			 	  				  vs.danweiID = obj.session[0].UnitID;
			 	  			   }
			 	  			   
			 	  			   
			 	  			   //vs.zid = obj.session[0].zid;
			 	  			   vs.zid = (obj.session[0].zid).split(",")[0];  //站点id
			 	  			   vs.zName = (obj.session[0].zid).split(",")[1];//上页选中来的站点名称
			 	  			   //alert("尖峰平谷 vs.danweiID="+vs.danweiID + " vs.danweiName= "+vs.danweiName +"vs.zid = "+vs.zid +"vs.zName = "+vs.zName);
			 	  			   $('#topTitle').text(vs.zName);
			 	  			   
			 	  			   zhandianid = vs.zid;
			 	  			   if(zhandianid==undefined){
			 	  				zhandianid = obj.session[0].zid;
			 	  			   }
			 	  			   onlineFunc();
			 	  			   
			 	  			   console.log("站点id="+vs.zid);
			 	  			   //setSessionfunc('',vs.zid+','+vs.zName,'',(vs.danweiID+','+vs.danweiName));     // session存站点（第二个参）
			 	  			   
			 	  			   console.log("站点id="+vs.zid);
			 	  			   
			 	  			   
			 	  			   localStorage.setItem("userid", vs.userid);
			 	  			   localStorage.setItem("zid", vs.zid);
			            	 }
			                 //alert("userid="+vs.userid+"and unitID="+vs.unitID+"and userType="+vs.userType) ;
			               
				             if(vs.danweiID==undefined||vs.danweiID==''){
			                	 vs.danweiID=vs.unitID;
			                 }
			                if(vs.zid && vs.zid != '' && vs.zid != null && vs.zid!= undefined){
			                	vs.getUnitIData(vs.userid,vs.danweiID);// 括号里的是用户id,单位id
			                	vs.getData(vs.userid,vs.zid);        //括号里的是用户id，单位ID
			                }
			                //具体用户进来的操作
			                if(vs.userType==3){
			                	console.log("我的身份是具体用户");
			                	$(".backHome-box >a").css("display","none");// “返回首页”隐藏
			                }
				     }
			     });
			},
			//站点
			getUnitIData:function(sy_userid,sy_uniId){
				var unitData = this;
				// userid用户id,unitid单位id,unitid为空时表示调用多个单位的站点信息
			    var url="/bigscrenn/getSiteList?userid="+sy_userid+"&unitid="+sy_uniId;
			    console.log("进来站点的地址url="+url);
			     $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
                        //alert("站点列表="+data);
                       // js解析json串
                       var obj = JSON.parse(data);
                        //alert("记录数="+obj.total);//记录数
                       unitData.zhandian = obj.rows;// 分类后的站点（用户）
                       
                     //====
                       var zd=obj.rows;
                       for(var i = 0;i<unitData.zhandian.length;i++){
                    	   	$("#zhanDianDl").append('<dd><a class="zhanDian" cid='+obj.rows[i].CID+'>'+obj.rows[i].UNITNAME+'</a></dd>')
                       }
                       //====
                       
                       unitData.$nextTick(function() {
                    	   var arrr = $(".zhanDian");
                    	   // alert("arrr=="+arrr.length);
                    	   var firstACID = $(".zhanDian:first()").attr("cid");
                    	   localStorage.setItem("zid", firstACID);// 没有点击存储本页第一个的站点CID覆盖homecid
                    	   var thisCid="";
                    	   for (var n=0;n<arrr.length;n++){
                    		   arrr[n].index = n;
                    		   arrr[n].onclick = function(){
                    			   // alert($(this).text());
                    			   
                    			   thisCid = $(this).attr("cid");
                    			   console.log("thisCid="+thisCid);
                    			   setSessionfunc('',thisCid+','+$(this).text(),'',(unitData.danweiID+','+unitData.danweiName));     // session存站点（第二个参）
	                        	   window.location.href = "./specificUser.html";// 返回具体页面
                    		   }
                    		   
                    	   }
                       });
				     }
			     });
			},
			getData : function(userid,unitid) {
				var vm = this;
				// 参数userid用户id,unitid站点id
			    var url="/bigscrenn/getPeakList?userid="+userid+"&unitid="+unitid;
			     //alert("尖峰平谷地址 = "+url);
			    $.ajax({
				     cache: true,
				     type: "POST",
				     url:url,
				     data:"",
				     async: false,				   
				     success: function(data){
			                //alert("尖峰平谷左边列表数据==:"+data);
			               // js解析json串
			               var obj = JSON.parse(data);
			               // 选择列表数据
			               for (var i=0;i<obj.rows.length;i++){
			                   // alert(obj.rows[i].ID);// 选择项id值
			                   // alert(obj.rows[i].NAME);// 选择项名称
			                   // alert(obj.rows[i].CONVERSION);// 数据单位
			            	   vm.kehu.push({
									"name" : obj.rows[i].NAME,
									"id" : obj.rows[i].ID,
									"jfpgDanwei":obj.rows[i].CONVERSION
								});
			                   
			               }
			               
			               vm.$nextTick(function() {
			            	   var m = $(".show input").val(); //获取单选时间的默认想月
			            	   $("#dl>dd:first() a").addClass("sideActive");
			            	   
								// 打开页面默认数据开始
								$("#thisTitle").text($("#dl>dd:first() a").text());// 默认选中第一对应标题
								var defaultID = $("#dl>dd:first() a").attr("id");
								
								var url="/bigscrenn/getPeakStatistics?userid="+vm.userid+"&unitid="+vm.zid+"&itemid="+defaultID+"&sdate="+m;
								//alert("默认接口地址为=："+url);
								getDataFunc(url);
								
								var jfpgDanwei = $("#dl>dd:first() a").attr("danwei");
								localStorage.setItem("jfpgDanwei",jfpgDanwei);      //存储当前的选项单位（v|A|其他）
								// 打开页面默认数据结束
								layui.use('element', function() {
									var element = layui.element; // 导航的hover效果、二级菜单等功能，需要依赖element模块

									// 监听导航点击
									element.on('nav(demo)', function(elem) {
										// console.log(elem)
										// alert(elem.text());
										
										$("#dl>dd a").removeClass("sideActive");
										$(this).addClass("sideActive");
										
										$("#thisTitle").text(elem.text());                                // 选中选项对应标题
										
										//监测点击事件单选事件
										if($(".show >input").length==1){
											dateStart = $(".show input").val();
											dateEnd = '';
										}
										if($(".show >input").length==2){
											dateStart = $(".show input").eq(0).val();
											dateEnd = $(".show input").eq(1).val();
										}
										//获取当前日|月|年
										dateType = $('.xz').find('input').attr('dateType'); 
										
										//获取当前左边选中的ID
										leftListID = $(".sideActive").attr('id');       
										
										var currentID = $(this).attr("id");                               //获取点击当前的选项id
										var danweiID = $(this).attr("danwei"); 
										
										
										localStorage.setItem("danweiID",danweiID); 
										
										
										//alert("点击侧边 leftListID="+elem.text()+" dateType ="+dateType);
										
										var url="/bigscrenn/getPeakStatistics?userid="+vm.userid+"&unitid="+vm.zid+"&itemid="+currentID+"&type="+dateType+"&sdate="+dateStart;
										//alert("此时的尖峰平谷的接口地址=:"+url);
										localStorage.setItem("jfpgURL",url);   //存储地址
										//var url="/bigscrenn/getPeakStatistics?userid=0100000000000004&unitid=000000000001&itemid=A00000000011&type=1&sdate=2018-12";
										getDataFunc(url);
									});
								});
							})           
				     }
			     });
			}
		}
	})
	
	
   //点击月/年操作
	$(".am-radio-inline").removeClass('xz');
	$(".am-radio-inline").eq(0).addClass('xz');
	var JFPGShiRi = $(".am-radio-inline");
	JFPGShiRi.click(function() {
		sDate=$(".show >input").val();
		//alert("sDate="+sDate);
		var index = JFPGShiRi.index(this);
		$(".am-radio-inline").removeClass('xz');
		$(".am-radio-inline").eq(index).addClass('xz');
		
		//监测点击事件单选事件
		if($(".show >input").length==1){
			dateStart = $(".show input").val();
			dateEnd = '';
		}
		if($(".show >input").length==2){
			dateStart = $(".show input").eq(0).val();
			dateEnd = $(".show input").eq(1).val();
		}
		//获取当前日|月|年
		dateType = $(this).find('input').attr('dateType'); 
		
		//获取当前左边选中的ID
		leftListID = $(".sideActive").attr('id');         
		
		//alert("vm.userid = "+vm.userid+ " vm.zid = "+vm.zid +" dateType = "+dateType +" leftListID = "+leftListID+" dateStart = "+dateStart+" dateEnd = "+dateStart);
		
		//var url = publcStr+"&itemid="+leftListID+"&type="+dateType+"&sdate="+sDate;
		var url = "/bigscrenn/getPeakStatistics?userid="+vm.userid+"&unitid="+vm.zid+"&itemid="+leftListID+"&type="+dateType+"&sdate="+dateStart;
		console.log("点击后的url=:"+url);
		//alert("点击后的url=:"+url);
		getDataFunc(url);
	})
	
	
}

function func(){
	//监测点击事件单选事件
	if($(".show >input").length==1){
		dateStart = $(".show input").val();
		dateEnd = '';
	}
	if($(".show >input").length==2){
		dateStart = $(".show input").eq(0).val();
		dateEnd = $(".show input").eq(1).val();
	}
	//获取当前日|月|年
	dateType = $('.xz').find('input').attr('dateType'); 
	
	//获取当前左边选中的ID
	leftListID = $(".sideActive").attr('id');
	
    //	var url="/bigscrenn/getPeakStatistics?userid=0100000000000004&unitid=000000000001&itemid=A00000000010&type=1&sdate=2018-12";
	var url = "/bigscrenn/getPeakStatistics?userid="+vm.userid+"&unitid="+vm.zid+"&itemid="+leftListID+"&type="+dateType+"&sdate="+dateStart;
	//alert("查询url="+url);
	getDataFunc(url);
}
//getDataFunc();
//得到指定站点尖峰平谷分析统计(非首页使用)
function getDataFunc(url){
	//alert("进来的地址为url="+url);
	var NAME1 =[], NUMA1 = [], NUMB1 = [],
	    NAME2 =[], NUMA2 = [], NUMB2 = [],
	    NAME3 =[], NUMA3 = [], NUMB3 = [],
	    NAME4 =[], NUMA4 = [], NUMB4 = [],
	    jfpgXArr = [];
	var  jfpgPieArr=[];                // 尖峰平谷饼图;
	var  totalNum = [],totalMoney = [];
	var numJ=0,numF=0,numP=0,numG=0;//电量数据
	var MJ=0,MF=0,MP=0,MG=0;       //电量费数据
    //参数userid用户id,unitid站点id,itemid统计项目id,type统计类型 1 月 2 年  ,sdate 日期 统计类型为1时是年月   统计类型为1时是年
    //var url="/bigscrenn/getPeakStatistics?userid=0100000000000004&unitid=000000000001&itemid=A00000000011&type=1&sdate=2018-12";
     $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
	    	 console.log("尖峰平谷数据="+data);
	    	 if(data&&data!=''&&data!=null){
	             //js解析json串
	             var obj = JSON.parse(data);
	             for (var i=0;i<obj.frows.length;i++){
	                   //alert(obj.frows[i].ITEM);//项目
	                   //alert(obj.frows[i].DATA);//数据
	          	     jfpgXArr.push(obj.frows[i].ITEM)  //x轴
	                   var obj1 = JSON.parse(obj.frows[i].DATA);
	                   for (var j=0;j<obj1.rows.length;j++){
	                       /*alert(obj1.rows[j].NAME1);//尖名称
	                       alert(obj1.rows[j].NUMA1);//尖数据
	                       alert(obj1.rows[j].NUMB1);//尖电费
	                       
	                       alert(obj1.rows[j].NAME2);//峰名称
	                       alert(obj1.rows[j].NUMA2);//峰数据
	                       alert(obj1.rows[j].NUMB2);//峰电费
	                       
	                       alert(obj1.rows[j].NAME3);//平名称
	                       alert(obj1.rows[j].NUMA3);//平数据
	                       alert(obj1.rows[j].NUMB3);//平电费
	                       
	                       alert(obj1.rows[j].NAME4);//谷名称
	                       alert(obj1.rows[j].NUMA4);//谷数据
	                       alert(obj1.rows[j].NUMB4);//谷电费                                     
	  */       
	                  	 NAME1.push(obj1.rows[j].NAME1);
	                  	 NUMA1.push(obj1.rows[j].NUMA1);
	                  	 NUMB1.push(obj1.rows[j].NUMB1);
	                  	 
	                  	 NAME2.push(obj1.rows[j].NAME2);
	                  	 NUMA2.push(obj1.rows[j].NUMA2);
	                  	 NUMB2.push(obj1.rows[j].NUMB2);
	                  	 
	                  	 NAME3.push(obj1.rows[j].NAME3);
	                  	 NUMA3.push(obj1.rows[j].NUMA3);
	                  	 NUMB3.push(obj1.rows[j].NUMB3);
	                  	 
	                  	 NAME4.push(obj1.rows[j].NAME4);
	                  	 NUMA4.push(obj1.rows[j].NUMA4);
	                  	 NUMB4.push(obj1.rows[j].NUMB4);
	                  	 //电量数据处理
	                  	 
	                  	 //alert(sum([obj1.rows[j].NUMA3,obj1.rows[j].NUMA2,obj1.rows[j].NUMA1]))
	                  	 //parseInt(val);//字符串转为数字
	                  	 var num = sum([parseInt(obj1.rows[j].NUMA3),parseInt(obj1.rows[j].NUMA2),parseInt(obj1.rows[j].NUMA1),parseInt(obj1.rows[j].NUMA4)]);
	                  	 var money = sum([parseInt(obj1.rows[j].NUMB3),parseInt(obj1.rows[j].NUMB2),parseInt(obj1.rows[j].NUMB1),parseInt(obj1.rows[j].NUMB4)]);
	                  	 //alert("typeof=:"+typeof(money));
	                  	 totalNum.push(num);
	                  	 totalMoney.push(money);
	                  	 
	                  	 //==========
	                  	
	                   }
	             }
	            var newarr1 = [],newarr2=[],newarr3=[],newarr4=[];
	  			for (var i = 0; i < NUMA1.length; i++) {
	  				newarr1.push(parseFloat(NUMA1[i]));
	  			}
	  			for (var i = 0; i < NUMA2.length; i++) {
	  				newarr2.push(parseFloat(NUMA2[i]));
	  			}
	  			for (var i = 0; i < NUMA3.length; i++) {
	  				newarr3.push(parseFloat(NUMA3[i]));
	  			}
	  			for (var i = 0; i < NUMA4.length; i++) {
	  				newarr4.push(parseFloat(NUMA4[i]));
	  			}
	  			//饼图数据
	  			// 保留两位小数点 Math.round(zongdianLiang*100)/100
	  			jfpgPieArr.push(
	  			    {"name":"尖","value":Math.round(sum(newarr1)*100)/100},
	  				{"name":"峰","value":Math.round(sum(newarr2)*100)/100},
	  				{"name":"平","value":Math.round(sum(newarr3)*100)/100},
	  				{"name":"谷","value":Math.round(sum(newarr4)*100)/100})
	  			jfpgPieFunc(jfpgPieArr); // 调用尖峰平谷饼图	
	              //alert("尖峰平谷饼图jfpgXArr==="+JSON.stringify(jfpgPieArr));
	              
               	 numJ = sum(newarr1);// 尖总电量
               	 numF = sum(newarr2);// 峰总电量
               	 numP = sum(newarr3);// 平总电量
               	 numG = sum(newarr4);// 谷总电量
               	 
               	var Jmoney = [],Fmoney=[],Pmoney=[],Gmoney=[];
	  			for (var i = 0; i < NUMB1.length; i++) {
	  				Jmoney.push(parseFloat(NUMB1[i]));
	  			}
	  			for (var i = 0; i < NUMB2.length; i++) {
	  				Fmoney.push(parseFloat(NUMB2[i]));
	  			}
	  			for (var i = 0; i < NUMB3.length; i++) {
	  				Pmoney.push(parseFloat(NUMB3[i]));
	  			}
	  			for (var i = 0; i < NUMB4.length; i++) {
	  				Gmoney.push(parseFloat(NUMB4[i]));
	  			}
	  			MJ = sum(Jmoney);// 尖总电量费
              	MF = sum(Fmoney);// 峰总电量费
              	MP = sum(Pmoney);// 平总电量费
              	MG = sum(Gmoney);// 谷总电量费
	         }
	     }
     });
   //alert("NUMB4=:"+NUMB4);
     var jfpgDanwei = localStorage.getItem("jfpgDanwei");  //获取尖峰平谷的图标单位
     jianFengPinGuFunc(NUMA1, NUMA2, NUMA3, NUMA4,jfpgXArr,jfpgDanwei);
     //alert("--1-"+numJ+"-2--"+numF+"-3--"+numP+"-4--"+numG);
     //alert("--1-"+MJ+"-2--"+MG+"-3--"+MP+"-4--"+MF);
     //alert("总钱数="+sum([MJ,MG,MP,MF]));
     //alert("总电量="+sum([numJ,numG,numP,numF]));
     //去小数点后2位
     $("#j").text(Math.round(numJ*100)/100);
     $("#f").text(Math.round(numP*100)/100);
     $("#p").text(Math.round(numF*100)/100);
     $("#g").text(Math.round(numG*100)/100);
     var zongdianLiang = sum([numJ,numG,numP,numF]); //总电量渲染
     $("#num").text(Math.round(zongdianLiang*100)/100);
     var zongMoney = sum([MJ,MG,MP,MF]);
     $("#money").text(Math.round(zongMoney*100)/100);
     var ssArr = [];
     //alert("jfpgXArr="+JSON.stringify(jfpgXArr));
     for (var a=0;a<jfpgXArr.length;a++){
    	 jfpgXArr[a].index = a;
    	 ssArr.push({
 			"time": jfpgXArr[a],
 			"energyNum": totalNum[a],
 			"countMoney": totalMoney[a],
 		})
     }
     
     if(ssArr&&ssArr!=''){
    	 JFPGListDetailFunc(ssArr);
     }
     
}
//数组求和
function sum(arr) {
	var len = arr.length;
	if(len == 0) {
		return 0;
	} else if(len == 1) {
		return arr[0];
	} else {
		return arr[0] + sum(arr.slice(1));
	}
}

function jianFengPinGuFunc(arr1, arr2, arr3, arr4,shijian,title) {
	//近两个月的能耗比 开始
	
	if(title=="undefined" || title==null){title='Kwh'}
	var latelyEnergyChart = echarts.init(document.getElementById("jianfengpingggu-barEchar"));
	latelyEnergy_option = {
		backgroundColor: 'transparent',
		//backgroundColor: 'rgb(0, 35, 120, .36)',
		title: {
			text: '单位('+title+')',
			x: '2%',
			y:"5%",
			textStyle: {
				//文字颜色
				color: '#fff',
				//字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				//字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
				fontWeight: '100',
				//字体系列
				fontFamily: 'sans-serif',
				//字体大小
				fontSize: 18
			}
		},
		tooltip: {
			trigger: 'axis',
			axisPointer: {
				type: 'shadow'
			}
		},
		legend: {
			data: ['尖', '峰', '平', '谷'],
			align: 'left',
			left: 'right',
			top: '5%',
			right:'5%',
			textStyle: {
				color: "#fff",
				fontSize: 16
			},
			itemWidth: 30,
			itemHeight: 20,
			itemGap: 25
		},
		grid: {
			left: '5%',
			top: '20%',
			right: '5%',
			bottom: '15%',
			containLabel: true
		},
		xAxis: [{
			type: 'category',
			data: shijian,
			/*data: [
				'1',
				'2',
				'3',
				'4',
				'5',
				'6',
				'7',
				'8',
				'9',
				'10',
				'11',
				'12',
				'13',
				'14',
				'15',
				'16',
				'17',
				'18',
				'19',
				'20',
				'21',
				'22',
				'23',
				'24'
			],*/
			axisLine: {
				show: true,
				lineStyle: {
					color: "rgba(255,255,255,.1)",
					width: 1,
					type: "solid"
				},
			},
			axisTick: {
				show: false,
			},
			axisLabel: {
				interval: 0, 
				//formatter: '{value} 点',
				formatter: '{value}',
				// rotate:50,
				show: true,
				splitNumber: 3,
				textStyle: {
					fontFamily: "微软雅黑",
					color: "rgba(255,255,255,.6)",
					fontSize: '120%',
				},
			},
		}],
		yAxis: [{
			type: 'value',
			axisLabel: {
				formatter: '{value}',
				show: true,
				textStyle: {
					fontFamily: "微软雅黑",
					color: "rgba(255,255,255,.6)",
					fontSize: '120%',
				},
			},
			axisTick: {
				show: false,
			},
			axisLine: {
				show: true,
				lineStyle: {
					color: "rgba(255,255,255,.1	)",
					width: 1,
					type: "solid"
				},
			},
			splitLine: {
				lineStyle: {
					color: "rgba(255,255,255,.1)",
				}
			}
		}],
		series: [{
			name: '尖',
			type: 'bar',
			data: arr1,
			barWidth: '18%', //柱子宽度
			// barGap: 1, //柱子之间间距

			itemStyle: {
				normal: {
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
						offset: 0,
						color: '#3ca1ff'
					}, {
						offset: 1,
						color: '#0a73d5'
					}]),
					opacity: 1,
					barBorderRadius: 3,
				}
			}
		}, {
			name: '峰',
			type: 'bar',
			data: arr2,
			barWidth: '18%',
			// barGap: 1,
			itemStyle: {
				normal: {
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
						offset: 0,
						color: '#DE67F4'
					}, {
						offset: 1,
						color: '#1CDEE0'
					}]),
					opacity: 1,
					barBorderRadius: 3,
				}
			}
		}, {
			name: '平',
			type: 'bar',
			data: arr3,
			barWidth: '18%',
			// barGap: 1,
			itemStyle: {
				normal: {
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
						offset: 0,
						color: '#4DDB8E'
					}, {
						offset: 1,
						color: '#00FF00'
					}]),
					opacity: 1,
					barBorderRadius: 3,
				}
			}
		}, {
			name: '谷',
			type: 'bar',
			data: arr4,
			barWidth: '18%',
			// barGap: 1,
			itemStyle: {
				normal: {
					color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
						offset: 0,
						color: '#DE67F4'
					}, {
						offset: 1,
						color: '#C97ED6'
					}]),
					opacity: 1,
					barBorderRadius: 3,
				}
			}
		}, ]
	};
	latelyEnergyChart.setOption(latelyEnergy_option);
	$(document).ready(function() {
		latelyEnergyChart.resize();
	});
	window.addEventListener("resize", function() {
		latelyEnergyChart.resize();
	})
	
}
<!--近两个月的能耗比 结束-->

function jfpgPieFunc(jfpgArr) {
	var healthChart = echarts.init(document.getElementById("jianfengpinggu_Pie"));
	var health_option = {
		title: {
			show:false,
			text: 'xxx',
			x: 'center',
			textStyle: {
				//文字颜色
				color: '#fff',
				//字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				//字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
				fontWeight: '100',
				//字体系列
				fontFamily: 'sans-serif',
				//字体大小
				　　　　fontSize: 20
			}
		},

		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b}: {c} ({d}%)"
		},
		legend: {
			show:false,
			orient: 'horizontal',
			x: 'center',
			y: 'bottom',
			itemGap: 30,
			data: ['q', 'w'],
			textStyle: {
				//文字颜色
				color: '#fff',
				//字体风格,'normal','italic','oblique'
				fontStyle: 'normal',
				//字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
				fontWeight: '100',
				//字体系列
				fontFamily: 'sans-serif',
				//字体大小
				　　　　fontSize: 14
			}
		},
		series: [{
			name: '尖峰平谷',
			type: 'pie',
			radius: ['50%', '70%'],
			avoidLabelOverlap: false,
			label: {
				normal: {
					show: false,
					position: 'center'
				},
				emphasis: {
					show: true,
					textStyle: {
						fontSize: '30',
						fontWeight: 'bold'
					}
				}
			},
			labelLine: {
				normal: {
					show: false
				}
			},
			data:jfpgArr,
			/*data: [{
				"name": "q",
				"value": 234
			}, {
				"name": "w",
				"value": 24
			}],*/
			itemStyle: {
				normal: {
					color: function(params) {
						//自定义饼图颜色
						var colorList = [
							'#20B9CF', '#33B565',
							'#3EABFF', '#205BCF', '#0AB2E4', '#6FC9D6', '#08A0B7',
							'#5883D8', '#20CC98', '#0CB2E4'
						];
						return colorList[params.dataIndex]
					}
				}

			}
		}]
	};
	healthChart.setOption(health_option);
	$(document).ready(function() {
		healthChart.resize();
	});
	window.addEventListener("resize", function() {
		healthChart.resize();
	})
}

//尖峰平谷列表详情开始
//JFPGListDetailFunc()
function JFPGListDetailFunc(arr) {
	$("#ListDetaiBox").html('');
	if(arr&&arr!=''&&arr!=null){
		var gjStr = JSON.stringify(arr);
		localStorage.setItem("gjStr", gjStr);
		console.log("尖峰平谷列表详情 arr = "+gjStr);
		$("#ListDetaiBox").html('<table id="ListDetail"></table>');
		$('#ListDetail').bootstrapTable({
			data:arr,
			/*data: [{
					"time": "2018-11-16",
					"energyNum": 123,
					"countMoney": 332,
				}, {
					"time": "2018-11-16",
					"energyNum": 123,
					"countMoney": 332,
				}, {
					"time": "2018-11-16",
					"energyNum": 123,
					"countMoney": 332,
				}, {
					"time": "2018-11-16",
					"energyNum": 123,
					"countMoney": 332,
				}, {
					"time": "2018-11-16",
					"energyNum": 123,
					"countMoney": 332,
				}, {
					"time": "2018-11-16",
					"energyNum": 123,
					"countMoney": 332,
				},

			],*/
			columns: [{
					field: 'time',
					title: '时间',
				},
				{
					field: 'energyNum',
					title: '电量(kwh)',
				},
				{
					field: 'countMoney',
					title: '总价(元)',
				}

			]
		});
	}
	
}
//尖峰平谷列表详情 结束

//日期时间查询开始
$(function() {
	//日期时间选择开始
	laydate.render({
		elem: '#date', //指定元素
		value: '1989-10-14',
		theme: 'grid', //定义主题风格
		min: '2018-10-11 12:30:00',
		max: '2019-12-31 12:30:00',
	});
	$("#jfpgSearch").click(function() {
		$.ajax({
			type: "get",
			url: "../json/jianFengPingGu.json",
			async: false,
			dataType: "json",
			success: function(result) {
				alert("result=="+result);
				if(result != null && result.search.jianfengpinggu.length > 0) {
					//alert("--------"+result.search.jianfengpinggu[0].value); 
					jianFengPinGuFunc(result.search.jianfengpinggu[0].value, result.search.jianfengpinggu[1].value, result.search.jianfengpinggu[2].value, result.search.jianfengpinggu[3].value,result.search.time);
				}
			}
		});
	})
})
//日期时间查询结束

//点击详情开始
function openLayerFunc(id){
	var windowH = $(window).height();//浏览器时下窗口可视区域高度
	var gjStr = localStorage.getItem("gjStr");
	var gjArr = JSON.parse(gjStr);
	//========
	var jfpg = $("#JFPG").attr("id");
	
	console.log("推送消息id="+jfpg);
	var area = [];
	if(gjArr&&gjArr.length>0){//计算数据条数设置弹框高度
		tHeight = (gjArr.length)*37+33;
		if(tHeight>windowH){
			tHeight=windowH-400;
		}
	}else{
		tHeight= 138;
	}
	//alert("tHeight="+(tHeight)+"str="+tHeight.toString());
	area = ['1000px',tHeight.toString()+'px'];
	var title = '';
	if(id == jfpg){//当点击推送消息的详情时的操作
		setSessionfunc('','',jfpg);
		ifFunc('列表详情',area,jfpg);
	}
	
	function ifFunc(title,area,ID){
		layer.open({
			type: 2,
			title: false,
//			title:'实时告警详情',
			title:title,
			center:"center",
			closeBtn: 1,
			area: ['1010px', '500px'],
			resize:false,//是否允许拉伸
			//area: area,
			shadeClose: true,
			skin:"myskin",
			scrollbar:false,
			content: './tanKuang.html'
		});
		
		//layer 弹框标题、关闭x样式
		$('.myskin').css({
			'background':'#07256b'
		})
		$(".myskin a.layui-layer-ico").text('×').css({
			'color':'#fff',
			'fontSize':'2rem',
			'margin-top': '-15px',
			'background':'none'
		});
		$(".layui-layer-title").css({'color':'#fff',});
	}
	
	
}

//值班人员
//onlineFunc(zhandianid);
function onlineFunc(){
	//alert("online zhandianid = "+zhandianid);
	// unitid 是站点ID
	// var url="/bigtongji/getRotaList?unitid=000000000001";
	var url="/bigtongji/getRotaList?unitid="+zhandianid;
	 $.ajax({
	     cache: true,
	     type: "POST",
	     url:url,
	     data:"",
	     async: false,				   
	     success: function(data){
        // alert(data);
        console.log(data);
        var dataObj=eval("("+data+")");// 转换为json对象
        // alert(dataObj);
        // alert(dataObj);
        if(dataObj.rows.length>0){
    		 $("#onlineNotice").html('');
    		 for (var i = 0; i < dataObj.rows.length; i++) {
         		var cid= dataObj.rows[i].cid;
         		var name= dataObj.rows[i].rname;
         		var phone= dataObj.rows[i].phoneCode;
         		//alert(cid);
         		//alert("cid="+cid+"name="+name+"phone="+phone);
        		 $("#onlineNotice").append('<li><span>👨‍⚖️&nbsp;&nbsp;<span id="onlineName1">'+name+'</span>&nbsp;电话：</span><span>'+phone+'</span></li>');
         	  }
    	  }
    	 if(dataObj.rows.length==0){
    		$("#onlineNotice").html(''); 
    	 }
	     }
	 });

}
//值班人员结束

//返回上一级跳转逻辑处理
function bachFunc(){
	var urlsStr = localStorage.getItem("urls");
	var ss = JSON.parse(urlsStr);
	if(ss.sanji != undefined &&  ss.sanji !=''){
    	//alert(ss.sanji);
	    window.location.href = './specificHome.html';
    	return;
    }
    if(ss.erji != undefined && ss.erji !=''){
    	//alert(ss.erji);
	    window.location.href = './intlgMonitor.html';
	    return;
    }if(ss.yiji != undefined &&  ss.yiji !=''){
    	//alert(ss.yiji);
	    window.location.href = './pro_Home.html';
	    return;
    }else{
	   //alert(222)
    }
}
